package it.xiuxian.personcenter.activity

import android.widget.LinearLayout
import android.widget.Toast
import com.alibaba.android.arouter.facade.annotation.Route
import com.github.yoojia.inputs.AndroidNextInputs
import it.xiuxian.lib.base.App
import it.xiuxian.lib.base.ArouterAddress
import it.xiuxian.lib.base.BaseActivity
import it.xiuxian.lib.base.EditHintUtils
import it.xiuxian.lib.http.SPConfig
import it.xiuxian.lib.utils.*
import it.xiuxian.personcenter.R
import it.xiuxian.personcenter.databinding.ActivityMyUpdateLoginPwdBinding
import it.xiuxian.personcenter.presenter.UpdateLoginActivityPresenter


@Route(path = ArouterAddress.UPDATELOGINACTIVITY)
class UpdateLoginActivity:BaseActivity<UpdateLoginActivityPresenter>() {
   lateinit var binding: ActivityMyUpdateLoginPwdBinding
    var inputs: AndroidNextInputs?=null
    override val layoutId: Int
        get() = R.layout.activity_my_update_login_pwd
    override val presenter: UpdateLoginActivityPresenter
        get() = UpdateLoginActivityPresenter()

    override fun initView() {
       setTitle("修改登录密码")
         binding =getViewDataBinding<ActivityMyUpdateLoginPwdBinding>()
        inputs = ToastNextInputs()
        inputs!!.clear()
        (binding.include.re.layoutParams as LinearLayout.LayoutParams).setMargins(0,
            DensityUtil.getStatusPix(App.INSTANCE.applicationContext)+5,0,0)
        inputs!!.add(binding.etNewPwd, SchemeUtil.notEmpty(binding.etNewPwd))
        inputs!!.add(binding.etPass, SchemeUtil.notEmpty(binding.etPass))
        inputs!!.add(binding.etXin, SchemeUtil.notEmpty(binding.etXin))
       /*  binding.etNewPwd.setHint(EditHintUtils.setHintSizeAndContent("请输入原密码",14,true))
         binding.etPass.setHint(EditHintUtils.setHintSizeAndContent("请输入新密码",14,true))
         binding.etXin.setHint(EditHintUtils.setHintSizeAndContent("请再次输入新密码",14,true))*/
    }

    override fun initEvent() {
        binding.tvSure.setOnClickListener {
            if(inputs!!.test()){
                if(binding.etPass.text.toString()==binding.etXin.text.toString()){
                    mPresenter!!.updataLoginPwd(binding.etNewPwd.text.toString(),binding.etPass.text.toString())
                }else{
                    ToastUtil.showShort("密码不一致")
                }

            }

        }
    }

    fun setUI(data: String) {
        Toast.makeText(this,data, Toast.LENGTH_SHORT).show()
        finish()

    }
}